<include file="Public/header" />
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">学生管理</a>
        <a>
          <cite>批量导入</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="__URL__/insearch" method="post">
        <div class="layui-form-item">
        <if condition="$Think.session.type eq 2 ">
          <div class="layui-inline">
            <div class="layui-input-inline">
              <select name="schoolid" id="schoolid">
                  <option value="">请选择学校</option>
                  <option value="1">孝义中学</option>
                  <option value="2">孝义二中</option>
                  <option value="3">孝义三中</option>
                  <option value="4">孝义四中</option>
                  <option value="5">孝义五中</option>
                  <option value="6">孝义实验中学</option>
                  <option value="7">孝义华杰中学</option>
                  <option value="8">孝义艺苑中学</option>
                  <option value="0">教育局</option>
                </select>
            </div>
          </div>
          </if>
          <div class="layui-inline">
            <div class="layui-input-inline">
              <input type="text" name="title"  placeholder="请输入项目名称，支持模糊查询" autocomplete="off" class="layui-input">
            </div>
             <div class="layui-input-inline" style="margin-left: -60px;">
              <button class="layui-btn"  lay-submit lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </div>
          </div>
        </div>
        
          <!-- <input class="layui-input" placeholder="开始日" name="start" id="start">
          <input class="layui-input" placeholder="截止日" name="end" id="end"> -->
         <!--  <input type="text" name="tname"  placeholder="请输入帐号，支持模糊查询" autocomplete="off" class="layui-input" required  lay-verify="required">
          <button class="layui-btn"  lay-submit lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button> -->
        </form>
      </div>
      <xblock>
        <button class="layui-btn layui-btn-danger" onclick="check_admin2();"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn"  onclick="check_admin();"><i class="layui-icon"></i>添加</button>
        <button class="layui-btn layui-btn-primary">导入Excel模板请联系作者</button>
        <span class="x-right" style="line-height:40px">共有数据：<{$num}> 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>项目名称</th>
            <th>创建人</th>
            <th>学校</th>
            <th>状态</th>
            <th>创建时间</th>
            <th>导入学生</th>
            <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <volist name="stuin" id="vo" empty="暂时没有数据">
              <tr>
                <td>
                  <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='<{$vo.id}>'><i class="layui-icon">&#xe605;</i></div>
                </td>
                <td ><{$vo.id}></td>
                <td ><{$vo.title}></td>
                <td ><{$vo.iner}></td>
                <td ><{$vo.schoolid|getschool}></td>
                <!-- <td class="td-status"><span class="layui-btn layui-btn-small "><{$vo['status']==1?'启用':'禁用'}></span></td> -->
                <td class="td-status"><if condition="$vo['status'] eq 1 "><span class="layui-btn layui-btn-small ">启用</span>
                <else /> 
                <span class="layui-btn layui-btn-small layui-btn-disabled">禁用</span>
                </if></td>
                <td ><{$vo.intime|date="Y-m-d H:i:s",###}></td>
                <td><button class="layui-btn layui-btn-small" inid="<{$vo.id}>" onclick="check_upadmin(this);"><i class="fa fa-cloud-upload" aria-hidden="true"></i>&nbsp;导入</button></td>
                <td class="td-manage">
                <if condition="$Think.session.type neq 0 ">
                    <a onclick="user_stop(this,'<{$vo.id}>')" href="javascript:;"  title="<{$vo['status']==1?'启用':'禁用'}>">
                       <if condition="$vo['status'] eq 1 ">
                          <i class="layui-icon">&#xe616;</i>
                        <else /> 
                        <i class="layui-icon">&#x1007;</i>
                        </if>

                    </a>
                    <a title="编辑"  onclick="x_admin_show('编辑','__URL__/inedit/id/<{$vo.id}>')" href="javascript:;">
                      <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除" onclick="member_del(this,'<{$vo.id}>')" v="<{$vo.title}>" href="javascript:;">
                      <i class="layui-icon">&#xe640;</i>
                    </a>
                <else />
                无权操作
               </if>
              </td>
              </tr>
            </volist>
          <!-- <tr>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>1</td>
            <td>admin</td>
            <td>18925139194</td>
            <td>113664000@qq.com</td>
            <td>超级管理员</td>
            <td>2017-01-01 11:11:42</td>
            <td class="td-status">
              <span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span></td>
            <td class="td-manage">
              <a onclick="member_stop(this,'10001')" href="javascript:;"  title="启用">
                <i class="layui-icon">&#xe601;</i>
              </a>
              <a title="编辑"  onclick="x_admin_show('编辑','admin-edit.html')" href="javascript:;">
                <i class="layui-icon">&#xe642;</i>
              </a>
              <a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
                <i class="layui-icon">&#xe640;</i>
              </a>
            </td>
          </tr> -->
        </tbody>
      </table> 
      <div class="page" style="text-align: center;">
            <{$page}>
        <!-- <div>
          <a class="prev" href="">&lt;&lt;</a>
          <a class="num" href="">1</a>
          <span class="current">2</span>
          <a class="num" href="">3</a>
          <a class="num" href="">489</a>
          <a class="next" href="">&gt;&gt;</a>
        </div> -->
      </div>

    </div>
    <script>
      // layui.use('laydate', function(){
      //   var laydate = layui.laydate;
        
      //   //执行一个laydate实例
      //   laydate.render({
      //     elem: '#start' //指定元素
      //   });

      //   //执行一个laydate实例
      //   laydate.render({
      //     elem: '#end' //指定元素
      //   });
      // });
      layui.use('table', function(){
        var table = layui.table;
        
      });
      //验证添加按钮是否为超级管理员
      function check_admin(){
          if ('<{$Think.session.type}>'!=0) {
           x_admin_show('添加','__URL__/inadd');
          } else {
            layer.msg('无此权限，请联系学校管理员!',{icon: 5,time:2000});
          }
          //x_admin_show('添加','__URL__/tadd')" 
      
      }
      
      /*用户-停用*/
      function user_stop(obj,id){
            if ($(obj).attr('title')=='启用') {
                var mes='确定要禁用所有学生吗？';
            } else {
              mes='确定要启用所有学生吗？';
            }
          layer.confirm(mes+id,function(index){

              if($(obj).attr('title')=='启用'){
                //发异步把用户状态进行更改
                  $.get("<{:U('stuin_stop')}>",{id:id},function(data,status){
                        //alert("Data: " + data + "\nStatus: " + status);
                        if (data >= 1) {
                          $(obj).attr('title','禁用')
                          $(obj).find('i').html('&#x1007;');

                          $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已禁用');
                          layer.msg('已禁用!',{icon: 5,time:1000});
                        } else{
                          layer.msg('修改用户状态失败！，请联系管理员！');
                        } 
                  });
              }else{
                  $.get("<{:U('stuin_open')}>",{id:id},function(data,status){
                        //alert("Data: " + data + "\nStatus: " + status);
                        if (data >= 1) {
                            $(obj).attr('title','启用')
                            $(obj).find('i').html('&#xe616;');

                            $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                            layer.msg('已启用!',{icon: 6,time:1000});
                        } else {
                            layer.msg('修改用户状态失败！，请联系管理员！');
                        }
                  });
              }
              
          });
      };

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('<span style="color:red;">将删除该项目下导入的所有学生！</span><br>确认要删除-['+$(obj).attr('v')+']-吗？',function(index){
              //发异步删除数据
              $.get("<{:U('indel')}>",{id:id},function(data,status){
                  //alert("Data: " + data + "\nStatus: " + status);
                  if (data >= 1) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:2000});
                    //layer.msg('删除成功!',{icon: 6,time:2000});
                  } else{
                    layer.msg('删除失败！请联系管理员！',{icon: 5,time:1000});
                    //x_admin_close();
                  } 
                 
              });
              
          });
      };
      function delAll (argument) {
        var data = tableCheck.getData();
        //alert(data);
        layer.confirm('<span style="color:red;">将删除这些项目下导入的所有学生！</span><br>确认要删除？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            $.get("<{:U('delallin')}>",{id:data},function(data,status){
                  //alert("Data: " + data + "\nStatus: " + status);
                  if (data >= 1) {
                    layer.msg('成功删除'+data+'条数据', {icon: 1,time:2000});
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                  } else{
                    layer.msg('删除失败！请联系管理员！',{icon: 5,time:1000});
                    //x_admin_close();
                  } 
                 
              });
           
        });
      };
      function check_admin2(){
        if ('<{$Think.session.type}>'!=0) {
            delAll ();
          } else {
            layer.msg('无此权限，请联系学校管理员!',{icon: 5,time:2000});
          }
      };
      function up_check(x){
        var inid=x.getAttribute('inid');
        //alert(eid);
        $.get("<{:U('up_check')}>",{id:inid},function(data,status){
              //alert("Data: " + data + "\nStatus: " + status);
              if (data > 0) {
                layer.confirm('已上传过本次学生数据，确认重新上传？', {
                  title:'提示：',
                  skin: 'layui-layer-molv',
                  btn: ['确定','取消'] //按钮
                }, function(index){
                  x_admin_show('上传学生','__URL__/up_stu/id/'+inid);
                  //layer.msg('的确很重要', {icon: 1});
                });
              } else {
                  x_admin_show('上传学生','__URL__/up_stu/id/'+inid);
                  //location.href="__MODULE__/Exam/up_score/id/"+eid+'.html'; 
                  //alert(eid);
              }
               });
        //return false;
      };
      function check_upadmin(x){
        if ('<{$Think.session.type}>'!=0) {
          up_check(x);
           // x_admin_show('添加','__URL__/inadd');
          } else {
            layer.msg('无此权限，请联系学校管理员!',{icon: 5,time:2000});
          }
       
      }
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>